<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>DOM 鼠标事件类型</title>
    <style>
      div {
        width: 400px;
        margin: 20px auto;
        border: 1px solid red;
      }
      #block {
        width: 200px;
        height: 200px;
        margin: 10px auto;
      }
    </style>
  </head>
  <body>
    <div><button id="btn">鼠标事件</button></div>
    <div id="block"></div>
    <div id="text">文章内容</div>
    <script>
      const btn = document.getElementById("btn");

      btn.onclick = () => {
        console.log("click");
        if (event.shiftkey && event.altkey) {
          console.log("shift + alt");
        }
      };
      btn.onmousedown = () => console.log("mousedown");
      btn.onmouseup = () => console.log("mouseup");

      btn.oncontextmenu = () => console.log("contextmenu");

      const block = document.getElementById("block");
      block.onmouseover =
        block.onmousemove =
        block.onmouseout =
          (event) => {
            console.log(`${event.type} + ${event.pageX} + ${event.pageY}`);
          };
      const text = document.getElementById("text");
      text.onmousedown = () => {
        return false;
      };
      document.oncontextmenu = ()=>{
        return false;
      }
    </script>
  </body>
</html>
